<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="java.text.DecimalFormat"%>
<%@page import="com.tjsinfo.tjsoa.fileExpress.vo.TjsUserEmail"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>粮油集团办公自动化协作平台</title>
    <meta http-equiv="x-ua-compatible" content="ie=7" />
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="<%=basePath%>style/txlz7.css" rel="stylesheet" type="text/css" id="txlz7"/>
	<link rel="stylesheet" type="text/css" href="<%=basePath%>ajaxFramework/ext-2.1/resources/css/ext-all.css" />
	<script type="text/javascript" src="<%=basePath%>ajaxFramework/ext-2.1/adapter/ext/ext-base.js"></script>
	<script type="text/javascript" src="<%=basePath%>ajaxFramework/ext-2.1/ext-all-debug.js"></script>
	<style type="text/css">
			td {
				font:12px/170% "宋体", "新宋体", "黑体"; color:#000
			}
			th {
				font:12px/170% "宋体", "新宋体", "黑体"; color:#000
			}
         .trBgColor { background-color:#A4D7E8; cursor: hand;}
         
         .blist {
		    background-image: url(<%=basePath%>addresslist/images/m_icon06.gif) !important;
		}
		
		.bmenu {
		    background-image: url(<%=basePath%>addresslist/images/m_icon07.gif) !important;
		}
		.bxinjian {
		    background-image: url(<%=basePath%>addresslist/images/m_icon10.gif) !important;
		}
		.black_overlays{
			display: none;
			position: absolute;
			top: 0%;
			left: 0%;
			width: 100%;
			height: 100%;
			background-color: #C1EBFC;
			z-index:1002;
			-moz-opacity: 0.8;
			opacity:.80;
			filter: alpha(opacity=30);
		}
		.insertGroup {
			display: none;
			position: absolute;
			border: 1px solid #FFF;
			border-bottom:none;
			z-index:1002;
			overflow: auto;
		}
		.ErrorDiv {
			display: none;
			position: absolute;
			border: 1px solid #FFF;
			border-bottom:none;
			z-index:1002;
			overflow: auto;
		}
		.lan01{
background: url(<%=basePath%>images/lanbg01.gif) no-repeat 0 0; width:6px; height:24px;} 
.lan02{
background: url(<%=basePath%>images/lanbg02.gif) repeat-x; width:99%; height:24px;}            
.lan03{
background: url(<%=basePath%>images/lanbg03.gif) no-repeat; width:8px; height:24px;}             
.cha{
padding-top:3px;}
	</style>
	<link href="<%=basePath %>ajaxFramework/ext-2.1/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/ext-all-debug.js"></script>
    <script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/source/locale/ext-lang-zh_CN.js"></script>
    
    <script type='text/javascript' src='<%=basePath%>dwr/interface/TjsUserEmailBo.js'></script>
	<script type='text/javascript' src="<%=basePath%>dwr/engine.js"></script>
	<script type='text/javascript' src="<%=basePath%>dwr/util.js"></script>
	<%
		List<TjsUserEmail> list = (List<TjsUserEmail>)request.getAttribute("list");
		ResourceBundle bundle = ResourceBundle.getBundle("com.tjsinfo.tjsoa.fileExpress.properties.FileExpress");
		String expressFileSize = bundle.getString("expressFileSize");
		int pagecount = 0;
		if(list.size() != 0){
			pagecount = list.size();
		}
		String listUser_id = (String)request.getAttribute("listUser_id");
		if(listUser_id == null)listUser_id = "-1";
	 %>
	 <script language="JavaScript" type="text/javascript" >//最大数据量
var total="<%=pagecount %>";
//每页的显示量
var pagesize="17";
//一共有多少页
var pagenum=Math.ceil(total/pagesize);
//生成导航
var nowpage = 1;
function initpage(nowpage){
var pagenav='<a>共'+total+'条,共'+pagenum+'页&nbsp;&nbsp;当前为'+nowpage+'页</a>&nbsp;&nbsp; <a>跳转到';
pagenav += '<select onchange="goToPage(this.value);">';
for(i=1;i<=pagenum;i++){
	if(i==nowpage){
		pagenav += '<option value="'+i+'" selected="selected">'+i+'</option>';
	}else{
		pagenav += '<option value="'+i+'">'+i+'</option>';
	}
}
pagenav += '</select>页</a>';
if(pagenum != 0){
document.getElementById('page').innerHTML=pagenav;
}
}
//翻页
function goToPage(page){
var start=(page-1)*pagesize;
var max=page*pagesize;
for(vs=0;vs<total;vs++){
var obj=document.getElementById('item_' + vs);
obj.style.display="none";
}
if(max>total)max=total;
for(v=start;v<max;v++){
var obj=document.getElementById('item_' + v);
obj.style.display="block";
}
initpage(page);
}
//上一页
function up(nowpage){
if(nowpage>1)goToPage((nowpage-1));
}
//下一页
function down(nowpage){
if(nowpage<pagenum)goToPage((nowpage+1));
}
var intpage = 1;
window.onload = function(){
	document.getElementById("right").style.width = document.body.clientWidth-5;
	initpage(1);
	var tb = new Ext.Toolbar(
		{
			height:25
		}
	);
    tb.render('menu');
	tb.add(
	    {
	            text:'返回',
	            iconCls: 'daohang',
	        	handler: function(){
	        		location.href="<%=basePath%>tjsinfo/tjsoa/fileExpress/loginFileExpress.do";
				}
	    }
	    );
	tb.addFill();
    tb.addText('<img id="windowResize" src="<%=basePath%>images/m_icon05.gif;"><a style="font-weight:bold; color:black;line-height: 22px;">设置</a>&nbsp;&nbsp;&nbsp;');
}
</script>
  </head>
  
  <body>
  <div id="right" style="z-index: 19;height: 98%">
	<div id="menu" style="padding-top:4px;"></div>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">
      	<tr>
            <td width="100%" valign="top" height="100%">
               <div class="contab" style="height: 90%;width: 100%;margin-left: 0px;">
                  <table class="p_06" width="100%" border="0" cellspacing="0" id="mytable">
                    <tr align="center">
                        <th width="30%" style="text-align: center;">用户名</th>
                        <th width="25%" style="text-align: center;">最大容量</th>
                        <th width="25%" style="text-align: center;">最大发送文件大小</th>
                        <th width="20%" style="text-align: center;">操作</th>
                    </tr>
                    <%
                    	int i = 0;
                    	for (TjsUserEmail listUser : list) {
                    	String id = listUser.getUserEmailId().toString();
                    	String username = listUser.getTjsUser().getUserName();
                    	String username1 = username;
                    	if(username.length()>8)username=username.substring(0,8);
	                    String rongliang = new DecimalFormat("#########").format(listUser.getMaxReception()/1048576);
                    	String rongliang1 = rongliang;
                    	String fasong = new DecimalFormat("#########").format(listUser.getMaxExpress()/1048576);
                    	String fasong1 = fasong;
					%>
					<tr onmouseover='this.className="trBgColor"' onmouseout='this.className=""' id="item_<%=i %>">
						<td><a title="<%=username1 %>"><%=username %></a></td>
						<td><div id="rl<%=i %>"><a title="<%=rongliang1 %>"><%=rongliang %>M</a></div><div id="gairl<%=i %>" style="display: none"><input value="<%=rongliang1 %>" id="rlinput<%=i %>" size="10" type="text" style="text-align: center">M</div></td>
						<td><div id="fs<%=i %>"><a title="<%=fasong1 %>"><%=fasong %>M</a></div><div id="gaifs<%=i %>"<%=i %> style="display: none"><input value="<%=fasong1 %>" id="fsinput<%=i %>" size="10" type="text" style="text-align: center">M</div></td>
						<td><div id="jinupdatediv<%=i %>"><input type="button" value="修 改" onclick="jinxiugai(<%=i %>);"/></div>
						<div id="updatediv<%=i %>" style="display: none"><input type="button" value="确 定" onclick="xiugai(<%=i %>,'<%=id %>',<%=rongliang %>,<%=fasong %>);"/>
						<input type="button" value="取 消" onclick="fanhui(<%=i %>);"/>
						</div>
						</td>
					</tr>
					<%
						i++;
						}
                     %>
                      <tr align="center">
                        <td colspan="7">
                          <div class="pages" id="page">
                          </div>
                        </td>
                    </tr>
                 </table>
              </div>
            </td>
          </tr>
      </table>
</div>
<div id="blackdiv" class="black_overlays">
	<iframe style="width:100%;height:100%;filter:alpha(opacity=0);-moz-opacity:0"></iframe>
</div>
  </body>
  <script>
	for(vs=1;vs<total;vs++){
		var obj=document.getElementById('item_' + vs);
		obj.style.display="none";
		for(v=1;v<pagesize;v++){
			if(vs==v){
				var obj=document.getElementById('item_' + vs);
				obj.style.display="block";
			}
		}
	}
	
	function jinxiugai(i){
		document.getElementById("jinupdatediv"+i).style.display = "none";
		document.getElementById("rl"+i).style.display = "none";
		document.getElementById("fs"+i).style.display = "none";
		
		document.getElementById("updatediv"+i).style.display = "block";
		document.getElementById("gairl"+i).style.display = "block";
		document.getElementById("gaifs"+i).style.display = "block";
	}
	
	function xiugai(i,id,rongliang,fasong){
		var a = document.getElementById("rlinput"+i).value;
		var b = document.getElementById("fsinput"+i).value;
		var zhengze = /^[1-9]\d*$/;
		if(!zhengze.exec(a)){
			Ext.MessageBox.alert('提示框','<nobr>最大容量只能为正整数</nobr>');
			return;
		}
		document.getElementById("rlinput"+i).value = a;
		a = a*1048576;
		if(!zhengze.exec(b)){
			Ext.MessageBox.alert('提示框','<nobr>最大发送文件大小只能为正整数</nobr>');
			return;
		}else{
			var expressFileSize = <%=expressFileSize %>;
			if(b>expressFileSize){
				Ext.MessageBox.alert('提示框','<nobr>最大发送文件大小不能大于<%=expressFileSize %>M</nobr>');
				return;
			}
		}
		document.getElementById("fsinput"+i).value = b;
		b = b*1048576;
		TjsUserEmailBo.updateFileExpress(id,b,a,{
			callback:function() {
				//下拉框
				document.getElementById("rl"+i).innerHTML='<a title="'+(a/1048576).toFixed(0)+'">'+(a/1048576).toFixed(0)+'M</a>';
				document.getElementById("fs"+i).innerHTML='<a title="'+(b/1048576).toFixed(0)+'">'+(b/1048576).toFixed(0)+'M</a>';
				document.getElementById("gairl"+i).value = (a/1048576).toFixed(0);
				document.getElementById("gaifs"+i).value = (b/1048576).toFixed(0);
				fanhui(i);
				Ext.MessageBox.alert('提示框','<nobr>修改成功</nobr>');
			}
		});
	}
	
	function fanhui(i){
		document.getElementById("jinupdatediv"+i).style.display = "block";
		document.getElementById("rl"+i).style.display = "block";
		document.getElementById("fs"+i).style.display = "block";
		
		document.getElementById("updatediv"+i).style.display = "none";
		document.getElementById("gairl"+i).style.display = "none";
		document.getElementById("gaifs"+i).style.display = "none";
	}
</script>
</html>
